#include <allegro.h>

volatile long predkosc = 0;

void zwieksz_predkosc()
{
    predkosc++;
}
END_OF_FUNCTION(zwieksz_predkosc);
LOCK_VARIABLE(predkosc);
LOCK_FUNCTION(zwieksz_predkosc);

int mx=0,my=0,mb=0;
void myszka()
{
if( mx != mouse_x || my != mouse_y || mb != mouse_b)
{
mx = mouse_x;
my = mouse_y;
mb = mouse_b;
}
};

int main()
{
    allegro_init();
    install_keyboard();
    install_mouse();
          show_mouse(screen);
            unscare_mouse();
    set_color_depth(16);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED,800,600,0,0);
    install_timer();
          show_mouse(screen);
    install_int_ex(zwieksz_predkosc,BPS_TO_TIMER(60));
    BITMAP *bufor = NULL;
    BITMAP *ludek = NULL;
    bufor = create_bitmap(800,600);
    if(!bufor)
    {
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Nie moge utworzyc bufora");
        allegro_exit();
        return 0;

    }
    ludek = load_bmp("tlo.bmp",default_palette);
    if(!ludek)
        {
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Nie moge zaladowac ludek.bmp");
        allegro_exit();
        return 0;
    }

    while(!key[KEY_ESC])
    {
                 show_mouse(screen);

        myszka();

        while ( predkosc > 0)
        {
            predkosc--;
        }

   FONT *myfont;
      PALETTE palette;
      myfont = load_font("d.pcx", NULL, NULL);


        clear_to_color(bufor,makecol(150,150,150));
        masked_blit(ludek,bufor,0,0,0,0,ludek->w,ludek->h);
        textprintf_ex(bufor,font,20,20,makecol(200,200,200),-1," x = %d, y = %d,  = %d !", mx,my,mb);
        if (((mx>620) && (mx<680)) && ((my>85) && (my<115))){
        textout_ex(bufor,font,"Uzyj kola ratunkowego - skresla 2 zle odpowiedzi",400,20,makecol(0,0,0),-1);
        }
                textout_ex(bufor,myfont,"W ktorym roku byla premiera Windows 95?",30,75,makecol(0,0,0),-1);
                textout_ex(bufor,myfont,"A :  1993",40,420,makecol(0,0,0),-1);
                textout_ex(bufor,myfont,"B :  1994",320,420,makecol(0,0,0),-1);
                textout_ex(bufor,myfont,"C :  1995",40,500,makecol(0,0,0),-1);
                textout_ex(bufor,myfont,"D :  1996",320,500,makecol(0,0,0),-1);
        blit(bufor, screen,0,0,0,0,800,600);

    }
        unscare_mouse();
    remove_int(zwieksz_predkosc);
    destroy_bitmap(ludek);
     destroy_bitmap(bufor);
     allegro_exit();
     return 0;
}
END_OF_MAIN();
